package com.qall.util;


import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;
import java.util.function.Function;

public class ZookeeperUtil {
    public static ZooKeeper connect(String address, int timeOut, Function<WatchedEvent, Object> function) {
        ZooKeeper zooKeeper = null;
        try {
            zooKeeper = new ZooKeeper(address, timeOut, watchedEvent -> function.apply(watchedEvent));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return zooKeeper;
    }
}
